package fi.profecons.csswindows;

import org.apache.commons.fileupload.ProgressListener;

import fi.profecons.csswindows.toolkit.FileUpload;

class FileUploadProgressListener implements ProgressListener {
	private FileUpload fileUpload;

	public FileUploadProgressListener(FileUpload fileUpload) {
		this.fileUpload = fileUpload;
	}

	public void update(long pBytesRead, long pContentLength, int pItems) {
		if (pContentLength == -1) {
			// Pituutta ei ole
		} else {
			int percent = (int) (pBytesRead * 100 / pContentLength);
			fileUpload.updateUploadStatus(percent);
		}
	}
}
